package com.java.utils;

import lombok.Data;

import java.util.List;

/**
 * 分页
 */
@Data
public class PageInfo<T> {
    //1.当前页
    private Integer page;
    //2.每页显示条数
    private Integer size;
    //3.总个数
    private Integer count;
    //4.总页数
    private Integer pages;
    //5.起始索引
    private Integer offset;
    //6.具体的数据
    private List<T> list;

    public PageInfo(Integer page, Integer size, Integer count) {
        this.page = page < 1 ? 1:page;
        this.size = size < 1 ? 5:size;
        this.count = count;
        this.pages=(int)(Math.ceil(this.count*1.0/this.size));
        this.offset=(this.page-1)* this.size;
    }
}
